home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / tstse13.zip / RNGEFIND.S < prev    next >
Text File  |  1995-02-12  |  3KB  |  108 lines

  1. /* Find low ascii or high ascii characters in a file. A macro for
  2.    SemWare's TSE editor V2.0. To make this SAL macro operational,
  3.    invoke the main menu (F10), choose "Macro", choose "Compile" and
  4.    press Enter at "Execute Macro".
  5.  
  6. ..................................................................
  7. Prof. Timo Salmi      Co-moderator of comp.archives.msdos.announce
  8. Moderating at garbo.uwasa.fi anonymous FTP archives  193.166.120.5
  9. Department of Accounting and Business Finance; University of Vaasa
  10. Internet: ts@uwasa.fi   BBS +(358)-61-3170972; FIN-65101,  Finland
  11. */
  12.  
  13. // The contents of a simple help, tied later to the CtrlAlt-H key
  14. helpdef tHelpData
  15.   title = "RNGEFIND.S HELP"       // The help's caption
  16.   x = 10                          // Location
  17.   y = 3
  18.   // The actual help text
  19.   " Prof. Timo Salmi's rangefind."
  20.   ""
  21.   " Find low ascii or high ascii characters in "
  22.   " a file. Searches forward from the current "
  23.   " position. "
  24.   ""
  25.   " Low ascii is from 1 to 31 excluding formfeed. "
  26.   " High ascii is ascii 126 and above. "
  27.   ""
  28.   " You can use <F11> to invoke the command "
  29.   " menu after first exiting this help. "
  30.   ""
  31.   " Last updated Sun 12-February-1995 06:36:26 "
  32. end  /* tHelpData */
  33.  
  34. // Find if the file includes any in a range of characters
  35. proc tRangeFind(integer low, integer high)
  36.   integer i, ok
  37.   integer foundone = 0
  38.   string answer[34] = "y"
  39.   string s[10]
  40.   i = low
  41.   repeat
  42.     if lFind(chr(i),"")
  43.       foundone = 1
  44.       s = Str(CurrLine())
  45.       Message ("Found " + Chr(i) + " (ascii " + Str(i) + ") on line " + s)
  46.       NextChar()
  47.       _ask:
  48.       ok = Ask ("Continue forward range-search y/n?", answer)
  49.       if not ok goto _end2 endif
  50.       if (answer == "n")
  51.         goto _end2
  52.       elseif (answer == "y")
  53.       else
  54.         Alarm()
  55.         goto _ask
  56.       endif
  57.     else
  58.       i = i+1
  59.     endif
  60.   until (i == high)
  61.   if foundone
  62.     Message ("No more finds between ascii " + Str(low)+ " and " + Str(high))
  63.   else
  64.     Message ("No finds between ascii " + Str(low) + " and " + Str(high))
  65.   endif
  66. _end2:
  67. end tRangeFind
  68.  
  69. // New keys and menus **************************************************
  70. forward Menu tRangeFindMenu()
  71. forward proc tDisableNewKeys()
  72.  
  73. // Add the new key definitions
  74. keydef new_keys
  75.   <CtrlAlt 4>      tRangeFind(1,11)
  76.   <CtrlAlt 5>      tRangeFind(13,31)
  77.   <CtrlAlt 6>      tRangeFind(126,255)
  78.   <CtrlAlt 0>      tDisableNewKeys()
  79.   <CtrlAlt H>      QuickHelp(tHelpData)
  80.   <F11>            tRangeFindMenu()
  81. end
  82.  
  83. // Disabling the new extra keys ***************************************
  84. proc tDisableNewKeys()
  85.   if YesNo("Disable the extra keys:") == 1 Disable(new_keys) endif
  86. end
  87.  
  88. // The range-find menu ************************************************
  89. Menu tRangeFindMenu()
  90.   Title = "Timo's range-find menu"
  91.   Width = 19
  92.   x = 40
  93.   y = 3
  94.   history
  95.   "Find &1-11 low ascii     <CtlrAlt 4>"   , tRangeFind(1,11)
  96.   "Find 13-31 &low ascii    <CtlrAlt 4>"   , tRangeFind(13,31)
  97.   "&Find 126-255 high ascii <CtlrAlt 6>"   , tRangeFind(126,255)
  98.   "",,Divide
  99.   "Disable &new keys        <CtrlAlt 0>"   , tDisableNewKeys()
  100.   "&Help                    <CtrlAlt H>"   , QuickHelp(tHelpData)
  101.   "This &Menu               <F11>"
  102. end  /* tRangeFindMenu */
  103.  
  104. proc Main()
  105.   Enable (new_keys)
  106.   tRangeFindMenu()
  107. end
  108.